﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Org.BouncyCastle.Asn1;

namespace TheClerk.Forms.Templates.raw.Envelope
{
    #region public Stamps
    /// <summary>
    /// Container for Stamp
    /// </summary>
    /// <remarks>
    /// -- The Stamps are just Assertions that are outside the Payload and unencrypted.
    /// Stamps ::= SEQUENCE(0..MAX) OF Stamp
    /// </remarks>
    public class Stamps
    {
        List<Stamp> data = new List<Stamp>();
        internal void Add(Stamp content)
        {
            data.Add(content);
        }

        internal Stream Serialize()
        {
            MemoryStream s = new MemoryStream();
            var o = new DerSequenceGenerator(s);
            foreach (var i in data)
                o.AddObject(i.ToAsn1Encodable());
            o.Close();
            s.Seek(0, SeekOrigin.Begin);
            return s;
        }

        internal Asn1Encodable ToAsn1Encodable()
        {
            return Asn1Sequence.FromStream(Serialize());
        }

    }
    #endregion
}
